home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / base-files.postinst < prev    next >
Text File  |  2008-10-20  |  5KB  |  161 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. install_local_dir() {
  5.   if [ ! -d $1 ]; then
  6.     mkdir -p $1
  7.   fi
  8.   #chown root:staff $1 2> /dev/null || true
  9.   #chmod 2775 $1 2> /dev/null || true
  10. }
  11.  
  12. install_from_default() {
  13.   if [ ! -f $2 ]; then
  14.     cp -p $1 $2
  15.   fi
  16. }
  17.  
  18. install_directory() {
  19.   if [ ! -d /$1 ]; then
  20.     mkdir /$1
  21.     chown root:$3 /$1
  22.     chmod $2 /$1
  23.   fi
  24. }
  25.  
  26. preserve_directory() {
  27.   if [ -f /etc/base-files.create-$1 ]; then
  28.     install_directory $1 755 root
  29.     rm -f /etc/base-files.create-$1
  30.   fi
  31. }
  32.  
  33. if [ "$1" = "configure" ] && [ "$2" = "" ]; then
  34.   install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf
  35.   install_from_default /usr/share/base-files/dot.profile   /root/.profile
  36.   install_from_default /usr/share/base-files/dot.bashrc    /root/.bashrc
  37.   install_from_default /usr/share/base-files/profile       /etc/profile
  38.   install_from_default /usr/share/base-files/motd          /etc/motd
  39.   install_from_default /usr/share/base-files/networks      /etc/networks
  40.   install_directory srv       755 root
  41.   install_directory opt       755 root
  42.   install_directory etc/opt   755 root
  43.   install_directory var/opt   755 root
  44.   install_directory media     755 root
  45.   install_directory var/mail 2775 mail
  46.   if [ ! -L /var/spool/mail ]; then
  47.     ln -s ../mail /var/spool/mail
  48.   fi
  49.  
  50.   install_local_dir /usr/local
  51.   install_local_dir /usr/local/share
  52.   install_local_dir /usr/local/share/man
  53.   install_local_dir /usr/local/bin
  54.   install_local_dir /usr/local/games
  55.   install_local_dir /usr/local/lib
  56.   install_local_dir /usr/local/include
  57.   install_local_dir /usr/local/sbin
  58.   install_local_dir /usr/local/src
  59.   install_local_dir /usr/local/etc
  60.   ln -sf share/man /usr/local/man
  61. fi
  62.  
  63. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  64.   if [ ! -d /var/spool/mail ] && [ ! -L /var/spool/mail ]; then
  65.     if [ -f /etc/base-files.mailsymlink ]; then
  66.       ln -sf `cat /etc/base-files.mailsymlink` /var/spool/mail
  67.     else
  68.       install_directory var/spool/mail 2775 mail
  69.     fi
  70.   fi
  71.   if [ ! -L /var/mail ] && [ ! -d /var/mail ]; then
  72.     ln -sf spool/mail /var/mail
  73.   fi
  74. fi
  75.  
  76. preserve_directory floppy
  77. preserve_directory cdrom
  78. preserve_directory initrd
  79.  
  80. if [ ! -f /etc/adjtime ]; then
  81.   echo "0.000000 1177000000 0.000000" > /etc/adjtime
  82.   echo "1177000000" >> /etc/adjtime
  83.   echo "UTC" >> /etc/adjtime
  84.   chmod 644 /etc/adjtime
  85. fi
  86.  
  87. if [ ! -f /var/run/utmp ]; then
  88.   echo -n>/var/run/utmp
  89. fi
  90. if [ ! -f /var/log/wtmp ]; then
  91.   echo -n>/var/log/wtmp
  92. fi
  93. if [ ! -f /var/log/btmp ]; then
  94.   echo -n>/var/log/btmp
  95. fi
  96. if [ ! -f /var/log/lastlog ]; then
  97.   echo -n>/var/log/lastlog
  98. fi
  99. chown root:utmp /var/run/utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  100. chmod 664 /var/run/utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  101.  
  102. if [ ! -d /var/lib/dpkg ]; then
  103.   mkdir -m 755 -p /var/lib/dpkg
  104.   chown root:root /var/lib/dpkg
  105. fi
  106. if [ ! -f /var/lib/dpkg/status ]; then
  107.   echo > /var/lib/dpkg/status
  108.   chmod 644 /var/lib/dpkg/status
  109.   chown root:root /var/lib/dpkg/status
  110. fi
  111.  
  112. if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
  113.   install_from_default /usr/share/base-files/info.dir /usr/share/info/dir
  114.   chmod 644 /usr/share/info/dir
  115.   chown root:root /usr/share/info/dir
  116. fi
  117. rm -f /etc/base-files.mailsymlink
  118.  
  119. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  120.   newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
  121.   if [ -f /etc/motd.tail ]; then
  122.     oldmd=`awk 'NR > 1' /etc/motd.tail | md5sum | awk '{print $1}'`
  123.     if [ "$oldmd" != "$newmd" ]; then
  124.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  125.         mv /etc/motd.tail /etc/motd.tail.old
  126.         awk 'NR > 1' /usr/share/base-files/motd > /etc/motd.tail
  127.       fi
  128.     fi
  129.   elif [ -f /etc/motd ] && [ ! -L /etc/motd ]; then
  130.     oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
  131.     if [ "$oldmd" != "$newmd" ]; then
  132.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  133.         awk 'NR <= 2' /etc/motd > /etc/motd.new
  134.         awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
  135.         mv /etc/motd /etc/motd.old
  136.         mv /etc/motd.new /etc/motd
  137.       fi
  138.     fi
  139.   fi
  140.  
  141.   if [ -f /etc/profile ]; then
  142.     md5=`md5sum /etc/profile | cut -f 1 -d\ `
  143.     if grep -qw "$md5" /usr/share/base-files/profile.md5sums; then
  144.         cp /usr/share/base-files/profile /etc/profile
  145.     fi
  146.   fi
  147. fi
  148.  
  149. if [ -f /var/lib/dpkg/info/base.list ]; then
  150.   :> /var/lib/dpkg/info/base.list
  151.   rm -f /var/lib/dpkg/info/base.conffiles
  152.   echo
  153.   echo "Note: You have the old \`base' package installed"
  154.   echo "It is very important that you do not try to remove this package"
  155.   echo "using dpkg. Please read /usr/share/doc/base-files/README.base to"
  156.   echo "get rid of the \`base' package completely in a safe way."
  157.   echo
  158.   echo -n "Press <Return> to continue "
  159.   read dummy
  160. fi
  161.